import React from 'react';
import copy from 'copy-to-clipboard';
import {
  Message,
} from '@knownsec/react-component';
function copyText({text}){
  const handleCopyText=()=> {
    if ( copy(text)) {
      Message.show({
        pro: true,
        type: 'success',
        message: '内容已复制！',
        showClose: false,
      });
    }
  }
  return text?<span style={{cursor: "pointer"}} onClick={()=>{handleCopyText()}}>{text} 点击复制</span>:null
}
export default copyText
